class Solution {
public:
    int findMaxConsecutiveOnes(vector<int>& nums) {
        int flag = 0, max_flag = 0;
        for (int i=0; i<nums.size(); i++) {
            if (nums[i] != 1){
                flag = 0;
            }else{
                flag++;
                if (flag > max_flag){
                    max_flag = flag;
                }
            }
        }
        return max_flag;
    }
};